"""
4. 按以下要求写程序
    1. echo_server.py 程序同时响应多个客户端的请求，接收客户端的数据，在数据前面加上 "received: "，然后返回给客户端
    2. echo_client.py 程序持续地给服务端发送当前时间，每发一次就睡眠1秒钟
"""
from socket import *
from datetime import datetime
import time

cliSocket = socket(AF_INET,SOCK_STREAM)
addr = ('localhost',3301)
cliSocket.connect(addr)

for i in range(30):
    now = datetime.now().strftime("%F %T")
    cliSocket.send(now.encode())
    data = cliSocket.recv(2048)
    print(data.decode())
    time.sleep(1)

cliSocket.close()